<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:body>
        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">
                <h:form>
                    <p:panel >

                        <f:facet name="header" >
                            <h:outputLabel value="CREDIT COMPANY PAYMENT BILL ITEM SEARCH "/>
                            <h:panelGrid columns="5" >
                                <h:outputLabel value="From Date"/>
                                <p:calendar styleClass="dateTimePicker" id="fromDate" value="#{searchController.fromDate}" navigator="false" pattern="dd MMMM yyyy hh mm ss a" >      
                                </p:calendar>
                                <h:outputLabel value="To Date"/>
                                <p:calendar id="toDate" value="#{searchController.toDate}" navigator="false" pattern="dd MMMM yyyy hh mm ss a" >                                                                              
                                </p:calendar>
                                <p:commandButton id="btnSearch" ajax="false" value="Search All"  
                                                action="#{searchController.createCreditTableBillItemAll()}" onclick="onSubmitButton();"/>
                                <p:commandButton ajax="false" value="Search OPD"  
                                                action="#{searchController.createCreditTableBillItemOpd()}" onclick="onSubmitButton();"/>
                                <p:commandButton ajax="false" value="Search BHT"  
                                                action="#{searchController.createCreditTableBillItemBht()}" onclick="onSubmitButton();"/>
                                <p:spacer height="30"/><h:outputLabel/><h:outputLabel/><h:outputLabel/><h:outputLabel/>

                            </h:panelGrid>

                            <h:panelGrid columns="7">
                                <h:outputLabel value="Bill No"/>    
                                <h:outputLabel value="OPD Bill No"/>    
                                <h:outputLabel value="Bht No"/>
                                <h:outputLabel value="Credit Company"/>
                                <h:outputLabel value="Value"/>
                                <h:outputLabel value="Bank"/>
                                <h:outputLabel value="Check No"/>
                                <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.billNo}" />
                                <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.refBillNo}" />
                                <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.bhtNo}" />
                                <p:inputText autocomplete="off" value="#{searchController.searchKeyword.fromInstitution}" />
                                <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.netTotal}"  />   
                                <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.bank}" />
                                <p:inputText autocomplete="off" value="#{searchController.searchKeyword.number}"/>

                            </h:panelGrid>

                        </f:facet>                         



                        <p:dataTable id="tblBills" value="#{searchController.billItems}" var="b"   >
                            <p:column>
                                <p:commandButton ajax="false" value="View Bill" action="credit_company_bill_reprint" onclick="onSubmitButton();">
                                    <f:setPropertyActionListener value="#{b.bill}" target="#{creditCompanyBillSearch.bill}"/>
                                </p:commandButton>
                            </p:column>
                            <p:column headerText="Opd Bill No">
                                <h:outputLabel  value="#{b.referenceBill.insId}" />
                            </p:column>
                            <p:column headerText="BHT No">
                                <h:outputLabel  value="#{b.patientEncounter.bhtNo}" />
                            </p:column>
                            <p:column headerText="Credit Company"   >                               
                                <h:outputLabel value="#{b.bill.fromInstitution.name}" />
                            </p:column>                                                         
                            <p:column headerText="Billed at"  >
                                <h:outputLabel value="#{b.bill.createdAt}" >
                                    <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                </h:outputLabel>
                                <br/>
                                <h:panelGroup rendered="#{b.bill.cancelled}" >
                                    <h:outputLabel style="color: red;" value="Cancelled at " />
                                    <h:outputLabel style="color: red;" rendered="#{b.bill.cancelled}" value="#{b.bill.cancelledBill.createdAt}" >
                                        <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                    </h:outputLabel>
                                </h:panelGroup>                               
                            </p:column>  
                            <p:column headerText="Billed by" >                                
                                <h:outputLabel value="#{b.bill.creater.webUserPerson.name}" >                                      
                                </h:outputLabel>                                    
                                <br/>
                                <h:panelGroup rendered="#{b.bill.cancelled}" >
                                    <h:outputLabel style="color: red;" value="Cancelled at " />
                                    <h:outputLabel style="color: red;" rendered="#{b.bill.cancelled}" value="#{b.bill.cancelledBill.creater.webUserPerson.name}" >                                       
                                    </h:outputLabel>
                                </h:panelGroup>                                
                            </p:column>    
                            <p:column headerText="PaymentScheme"  >                             
                                <h:outputLabel value="#{b.bill.paymentScheme.name}" >                                       
                                </h:outputLabel>                                   
                            </p:column>
                            <p:column headerText="Paymentmethod" >                              
                                <h:outputLabel value="#{b.bill.paymentMethod}" >                                       
                                </h:outputLabel>                                
                            </p:column>
                            <p:column headerText="Net Value" styleClass="averageNumericColumn">                               
                                <h:outputLabel value="#{b.netValue}" >
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputLabel>                                    
                            </p:column>
                            <p:column headerText="Bank" >                              
                                <h:outputLabel value="#{b.bill.bank.name}" >                                        
                                </h:outputLabel>                                   
                            </p:column>
                            <p:column headerText="Cheque No" >                                
                                <h:outputLabel value="#{b.bill.chequeRefNo}" >                                       
                                </h:outputLabel>                                  
                            </p:column>
                            <p:column headerText="Cheque Date">                               
                                <h:outputLabel value="#{b.bill.chequeDate}" >
                                    <f:convertDateTime pattern="dd MM yyyy"/>
                                </h:outputLabel>                                   
                            </p:column>                                                  
                            <p:column headerText="Comments" >                             
                                <h:outputLabel  rendered="#{b.bill.cancelledBill ne null}" value="#{b.bill.cancelledBill.comments}" >
                                </h:outputLabel>
                            </p:column>
                        </p:dataTable>


                    </p:panel>

                </h:form>
            </ui:define>


        </ui:composition>

    </h:body>
</html>
